/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2020年9月4日
 */
package com.massyframework.beanskin.runtime.service;


import java.util.Map;

import com.massyframework.beanskin.service.ServicePropertiesBuilder;
import com.massyframework.beanskin.service.ServiceReference;

/**
 * {@link ServicePropertyExtendBuilder}, 服务属性扩展构建器
 */
class ServicePropertyExtendBuilder extends ServicePropertiesBuilder {

    /**
     * 创建新的构建器
     * @return {@link ServicePropertyExtendBuilder}
     */
    public static ServicePropertyExtendBuilder newBuilder(){
        return new ServicePropertyExtendBuilder();
    }

    /**
     * 使用{@code props}创建新的构建器
     * @param props {@link Map}
     * @return {@link ServicePropertyExtendBuilder}
     */
    public static ServicePropertyExtendBuilder newBuilder(Map<String, Object> props){
        return new ServicePropertyExtendBuilder(props);
    }


    /**
     * 构造方法
     */
    protected ServicePropertyExtendBuilder() {
    }

    /**
     * 构造方法
     * @param props {@link Map}
     */
    public ServicePropertyExtendBuilder(Map<String, Object> props) {
        super(props);
    }

    @Override
    public ServicePropertyExtendBuilder allowGroupId(String domain) {
        super.allowGroupId(domain);
        return this;
    }

    @Override
    public ServicePropertyExtendBuilder allowGroupIds(String[] domains) {
        super.allowGroupIds(domains);
        return this;
    }

    @Override
    public ServicePropertyExtendBuilder name(String value) {
        super.name(value);
        return this;
    }

    @Override
    public ServicePropertyExtendBuilder description(String value) {
        super.description(value);
        return this;
    }

    @Override
    public ServicePropertyExtendBuilder ranking(int value) {
        super.ranking(value);
        return this;
    }

    @Override
    public ServicePropertyExtendBuilder topRanking() {
        super.topRanking();
        return this;
    }

    /**
     * 设置服务类型
     * @param exportType {@link Class}
     * @return {@link ServicePropertyExtendBuilder}
     */
    public ServicePropertyExtendBuilder exportType(Class<?> exportType){
        this.property(ServiceReference.EXPORT_TYPES, new Class<?>[]{exportType});
        return this;
    }

    /**
     * 设置服务类型
     * @param exportTypes {@link Class}数组
     * @return {@link ServicePropertyExtendBuilder}
     */
    public ServicePropertyExtendBuilder exportTypes(Class<?>[] exportTypes){
        this.property(ServiceReference.EXPORT_TYPES, exportTypes);
        return this;
    }

    @Override
    public ServicePropertyExtendBuilder property(String name, Object value) {
        super.property(name, value);
        return this;
    }

    public Class<?>[] getExportTypes(){
        return this.getProperty(ServiceReference.EXPORT_TYPES, Class[].class);
    }
}

